import axios from 'axios'
import * as types from './action-types'

const getDetailData = (data) => ({
  type: types['SET_DETAIL_DATA'],
  data
})

export const getDetailDataAction = (id) => {
  return (dispatch) => {
    axios.get(`/api/detail.json?id=${id}`)
      .then(res => {
        const result = res.data
        if (result.success) {
          dispatch(getDetailData(result.data))
        }
      })
  }
}